﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xos_http.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __DATA_STRUCT_SESSION_H__
#define __DATA_STRUCT_SESSION_H__

#include "../tools/head.h"

namespace xos_http
{

    class session : public xos_stl::mem_item< xos::release_impl< session >, thread_lock >,
        public xos_http::i_session
    {
    public:
        typedef xos::release_impl< session > T;

    public:
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 
        static int get_addr( POOL *** pppPool, LIST *** pppList );

        static session * get( const char * lpszId );
        static int remove( session *& pSession );
        static int heart( int interval_ms );

        static int static_user_init();
        static int static_user_term();

    public:
        session();
        ~session();

    public:
        int m_nTimeToTimeout_ms;
        std::string m_id;

    protected:
        int init_data();

    public:
        int reset_timeout();
        int init();
        int term();

        // 
        // i_session method
        // 
    public:
        const char * id( const char * lpszId );
        
    };

} // xos_http

#endif // __DATA_STRUCT_SESSION_H__
